import 'babel-polyfill'
import Vue from 'vue'
import Router from 'vue-router'

/* home */
//const Index = () => import("page/home/index");
import Index from 'page/home/index'
/* cms */

/* member */
//const Login = () => import("page/member/login");
//const Address = () => import("page/member/address");
import Login from 'page/member/login'
import Address from 'page/member/address'
/* member */

/* shop */
import List from 'page/shop/list'
import Product from 'page/shop/product'
import CreateOrder from 'page/shop/createOrder'
import Pay from 'page/shop/pay'
import PaySuccess from 'page/shop/paySuccess'
import Cart from 'page/shop/cart'
/* shop */

const appRouter = {
  mode: 'history',
  base: '/m/',
  routes: [
    {
      path: '',
      redirect: '/index'
    },
    {
      path: '/index',
      name: 'index',
      component: Index,
      meta: {
        keepAlive: true,
        isBack: true //用于判断上一个页面是哪个
      }
    },
    {
      path: '/login',
      name: 'login',
      component: Login,
      meta: {
        keepAlive: false
      }
    },

    {
      path: '/list',
      name: 'list',
      component: List,
      meta: {
        keepAlive: true,
        isBack: false //用于判断上一个页面是哪个
      }
    },
    {
      path: '/product/:id',
      name: 'product',
      component: Product,
      meta: {
        keepAlive: false
      }
    },
    {
      path: '/createorder',
      name: 'createorder',
      component: CreateOrder,
      meta: { keepAlive: false }
    },
    {
      path: '/address/:id?',
      name: 'address',
      component: Address,
      meta: { keepAlive: false }
    },
    {
      path: '/pay',
      name: 'pay',
      component: Pay,
      meta: { keepAlive: false }
    },
    {
      path: '/paysuccess',
      name: 'paysuccess',
      component: PaySuccess,
      meta: { keepAlive: false }
    },
    {
      path: '/cart',
      name: 'cart',
      component: Cart,
      meta: { keepAlive: false }
    }
  ]
}
// import example from '@/router/example'
// example.map(i=>{appRouter.routes.push(i)}) // 部署线上记得吧这行代码注释掉
Vue.use(Router)
export default new Router(appRouter)
